Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend login form #110

Open
wants to merge 8 commits into
base: frontend
Choose a base branch
from
Open

Frontend login form #110

wants to merge 8 commits into from

Conversation

A-Wodnicki
Copy link
Member

obraz
obraz
obraz

@A-Wodnicki
Copy link
Member Author

  • wgrałem nowe zmienne z Figmy ale niektóre są bez jednostek i musiałem kombinować z mnożeniem przez jeden piksel
  • nie mamy jeszcze łososiowego loga więc wziąłem najbardziej podobne

@A-Wodnicki A-Wodnicki marked this pull request as ready for review August 2, 2023 19:18
@A-Wodnicki A-Wodnicki self-assigned this Aug 3, 2023
@A-Wodnicki A-Wodnicki linked an issue Aug 3, 2023 that may be closed by this pull request
@A-Wodnicki A-Wodnicki added the frontend Frontend tasks label Aug 3, 2023
gap: $form-gap;
text-align: center;
background-color: $alternative-a900;
border: 6px solid $primary-p700;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest change border width to rem cause everywhere you're using rem so it's good idea to keep consistency

border-radius: 0.625rem;
padding: 2.875rem 5.4375rem;

@media screen and (height > 45rem) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if resolution for media query should be define as rem unit. @marcol13 what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kapson007 yes, you are right. It should be defined in px unit.

}
}

h3 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we are using BEM but imo its better to use class selectors and avoid tag selectors as much as possible to control specificity properly.

}

.passwordReset {
margin-top: -$form-gap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the future its better to create another var rather than using like that beacuse now it's not semantic - using var for gaps in place for margins.

password: string().required('Pole "Hasło" jest wymagane.')
})

const handleChange = (event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ciekawe podejście. Powinno działać, ale lepiej użyć do tego useRef. Ten hook nie powoduje rerenderowania się elementu przy każdej zmianie (w tym przypadku na każdy onChange któregokolwiek z inputów), a walidacja w czasie rzeczywistym nie jest nam potrzebna (wystarczy jedynie sprawdzenie poprawności po kliknięciu przycisku). Jest to więc bardziej wydajny sposób na poradzenie sobie z formularzem 😉

https://levelup.gitconnected.com/react-forms-usestate-vs-useref-5cb584cc19fd

Według mnie lepszym podejściem byłoby zrobić refy na każdy input i po kliknięciu przycisku (czyli na onSubmit) odczytywać wartości inputów poprzez .current.value.

https://dev.to/sobhandash/react-forms-and-useref-hook-4p1l

Errory mogą być wtedy nadal przechowywane jako useState (bo będą wymuszały rerenderowanie pewnego fragmentu komponentu — komunikatu o błędzie).

}

return (
<div className={styles.view}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Z tego diva w późniejszym etapie będzie trzeba utworzyć jakiś nowy komponent 😉 Tak, żeby w pliku LoginForm.jsx był sam element form. Na razie niech tak to zostanie, ja się postaram ty zająć 😉

</div>
</header>
<form className={styles.form} ref={loginForm} onSubmit={handleSubmit}>
<header>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wydaje mi się, że w tym miejscu element header jest trochę niepotrzebny. Można go zastąpić zwykłym divem.

)}
<Button
style={styles.button}
onClick={() => loginForm.current.onSubmit}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tutaj, tak jak mówiliśmy na spotkaniu, możesz zmienić definicję komponentu Button, tak aby ten onClick nie był required. Wtedy nie będzie trzeba tu robić niepotrzebnych fikołków 😉

<span className={styles.errorSpan}>Nie udało się zalogować</span>
)}
<Button
style={styles.button}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Żeby nie było potem wątpliwości i definicji w SCSS button.button, możesz zmienić nazwę klasy na inną, np. styles.submitButton

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Możesz nawet nie zwracać specjalnie uwagi na złe stylowanie tego komponentu, bo Button.jsx jest do poprawy, także nie musisz tego na siłę dostosowywać w tym LoginFormie 😉 Ale oczywiście na razie możesz tak to zostawić 😄

@marcol13
Copy link
Collaborator

marcol13 commented Aug 7, 2023

Btw. świetna robota! Widok formularza wygląda praktycznie identycznie jak na makiecie. Kilka sugestii ode mnie i wcześniej od @Kapson007 😉

Copy link
Contributor

@PixelSculptor PixelSculptor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice, there are some comments to consider with team ;)

</div>
</header>
<form className={styles.form} ref={loginForm} onSubmit={handleSubmit}>
<h3 className={styles.header__level3}>Zaloguj się do swojego konta</h3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now is better but maybe we should avoid addicting to structure and only write just header or BEM element login__header?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

login__header sounds better 😄 header__level3 is a little bit confusing

grid-template-rows: auto 1fr;
align-items: center;
background-color: #282828;
color: $base-white;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please mark as TODO to refactor in the future this calculation with mixin

background-color: #282828;
color: $base-white;
font-size: calc($font-size-p * 1px);
font-weight: 600;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any var for font weight? @marcol13 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there are no variables for that. I am not sure if it is necessary, because in default font-weight values have specific meaning, e.g. 400 - normal, 600 - semibold.

What do you think about it? Should I add proper tokens for weight? @A-Wodnicki @PixelSculptor

background-color: $alternative-a900;
border: 0.375rem solid $primary-p700;
border-radius: 0.625rem;
padding: 2.875rem 5.4375rem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it expected to use these specific float values? @marcol13

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these values were copied directly from our Figma if they were available to check, I set it to display the values in rem units

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay approve ;) we need to figure out on our meeting how to round up/down these values

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can discuss that on our next meeting 😉 Because maybe not everything should be in rem

}
}

button.button {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you want raise specificity? I think here you don't need button selector

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Higher specificity was required to override some rules over button component without using !important

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried .form__button?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.form__button is more readable than button.button 😉

color: $alternative-a900;
font-weight: 600;
border-radius: $border-radius-md;
padding: 0.5625rem 1.875rem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same specific value

Copy link
Collaborator

@marcol13 marcol13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wygląda to bardzo dobrze! 🎉 Kilka małych komentarzy. Myślę, że jak je poprawisz to będzie można tego Pull Requesta mergować 😉

password: string().required('Pole "Hasło" jest wymagane.')
})

const handleChange = (event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Myślę, że teraz, gdy korzystamy z useRef, to ta funkcja nie jest nam za bardzo potrzebna 😉 Walidacja razem z ustawieniem błędów powinna się odbywać tylko po naciśnięciu przycisku. Po zmianie wartości w inputach nie potrzebujemy na bieżąco kontroli nad wartościami wpisywanymi przez użytkownika. Wprowadza to tylko niepotrzebne operacje 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Czyli błędy, które wcześniej się pojawiły mają się chować przy submicie? Ta funkcja je chowa jak wpisze się coś do inputa, w którym błąd wystąpił

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aaa rozumiem... Nie przewidywaliśmy w sumie takiego zachowania inputa — myślę, że dla prostoty i optymalizacji nie trzeba tutaj usuwać komunikatu o błędzie po wpisaniu tam czegokolwiek.

@@ -0,0 +1,15 @@
import React from 'react'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ogólnie to niekoniecznie potrzebne są nam w Storybooku całe widoki jako historyjki 😉 Bardziej nam będzie zależało, żeby tam znalazły się komponenty, ale kudosy za to, że to postawiłeś 😁 Myślę, że możesz tak to zostawić, ale w przyszłości nie jest wymagane, żebyś to aplikował dla całych stron 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Frontend tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Frontend] Formularz logowania
3 participants